package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.TScenicTicketDao;
import com.aaa.ssm.entity.TScenicTicket;
import com.aaa.ssm.service.TScenicTicketService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TScenicTicketServiceImpl implements TScenicTicketService {
    @Resource
    private TScenicTicketDao tmScenicTicketDao;
    @Override
    public PageInfo queryPage(Page<TScenicTicket> page) {
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        return new PageInfo(tmScenicTicketDao.queryPage(page.getData()));
    }

    @Override
    public List<TScenicTicket> queryAll() {
        return tmScenicTicketDao.queryAll();
    }

    @Override
    public TScenicTicket queryById(int id) {
        List<TScenicTicket> tScenicTicketList=tmScenicTicketDao.queryById(id);
        if (tScenicTicketList!=null&&tScenicTicketList.size()>0){
                 return tScenicTicketList.get(0);
        }
        return null;
    }

    @Override
    public int add(TScenicTicket tScenicTicket) {
        return tmScenicTicketDao.add(tScenicTicket);
    }

    /**
     * 获取门票
     * @param id
     * @return
     */
    @Override
    public List<TScenicTicket> getTickets(int id) {
        return tmScenicTicketDao.getTickets(id);
    }

    @Override
    public int update(TScenicTicket tScenicTicket) {
        try {
            tmScenicTicketDao.update(tScenicTicket);
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int deleteById(int id) {
        return tmScenicTicketDao.deleteById(id);
    }
    @Override
    public TScenicTicket queryticket(int id) {
        return tmScenicTicketDao.queryticket(id);
    }
}
